// 版权归陈超所有


#include "Characters/CC_EnemyCharacter.h"

#include "AbilitySystem/CC_AbilitySystemComponent.h"
#include "AbilitySystem/CC_AttributeSet.h"
#include "CC_Aura/CC_Aura.h"

//构造函数
ACC_EnemyCharacter::ACC_EnemyCharacter()
{
	//为网格设置碰撞响应
	GetMesh()->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);	//自定义碰撞，块碰撞

	//添加能力系统组件
	AbilitySystemComponent = CreateDefaultSubobject<UCC_AbilitySystemComponent>("AbilitySystemComponent");
	AbilitySystemComponent->SetIsReplicated(true); //设置组件用于在网络上复制
	AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Minimal);	//复制模式

	//添加属性集
	AttributeSet = CreateDefaultSubobject<UCC_AttributeSet>("AttributeSet");
}

void ACC_EnemyCharacter::BeginPlay()
{
	Super::BeginPlay();
	InitCharacterASC();
}

void ACC_EnemyCharacter::InitCharacterASC()
{	// 为敌人类初始化演员能力信息
	AbilitySystemComponent->InitAbilityActorInfo(this,this);
	Cast<UCC_AbilitySystemComponent>(AbilitySystemComponent)->AbilityActorInfoSet();
}

//高亮显示角色
void ACC_EnemyCharacter::HighlightActor()
{
	GetMesh()->SetRenderCustomDepth(true);	//是否渲染自定义深度
	GetMesh()->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED);		//自定义深度模板值

	Weapon->SetRenderCustomDepth(true);
	Weapon->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED);
}

//取消高亮显示角色
void ACC_EnemyCharacter::UnHighlightActor()
{
	GetMesh()->SetRenderCustomDepth(false);
	Weapon->SetRenderCustomDepth(false);
}
